package com.ui.fragment;

import android.support.v4.app.Fragment;

import com.frame.clean.CleanFragment;
import com.frame.flux.ui.FluxFragment;
import com.frame.mvp.MvpFragment;
import com.frame.mvvm.MvvmFragment;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description fragment工厂类
 * @Author luxiao418
 * @Email luxiao418@pingan.com.cn
 * @Date 16/8/11 17:44
 * @Version v2.6.0
 */
public class FragmentFactory {
    private static Map<String, Fragment> mFragments = new HashMap<>();
    public static Fragment get(String tab) {
        Fragment mFragment = null;
        mFragment = mFragments.get(tab);
        if (mFragment == null) {
            switch (tab) {
                case "home":
                    mFragment = new MainFragment();
                    break;
                case "frame":
                    mFragment = new FrameFragment();
                    break;
                case "hot":
                    mFragment = new HotFragment();
                    break;
                case "message":
                    mFragment = new MessageFragment();
                    break;
                case "mine":
                    mFragment = new MineFragment();
                    break;
                case "flux":
                    mFragment = new FluxFragment();
                    break;
                case "clean":
                    mFragment = new CleanFragment();
                    break;
                case "mvvm":
                    mFragment = new MvvmFragment();
                    break;
                case "mvp":
                    mFragment = new MvpFragment();
                    break;
            }
            mFragments.put(tab, mFragment);
        }
        return mFragment;
    }
}
